package com.lecture.java8.list;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author luyn
 * @version 1.0
 * @description
 * @date 2021/3/4 20:35
 */
public class ListRemove {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();

        list.add("a");
        list.add("a");
        list.add("b");
        list.add("c");
        list.add("g");
        list.add("e");
        list.add("b");
        list.add("c");



        List<String> newList = new ArrayList<>();

        for (int i = list.size()-1; i >= 0; i--) {
            if (newList.contains(list.get(i))) {
                System.out.println("包含：" + list.get(i));
                newList.remove(list.get(i));
                continue;
            }
            newList.add(list.get(i));
        }

        for (String s : newList) {
            System.out.println(s);
        }
    }
}
